import { positionList } from "@/api";

export const gender = () => {
  return [
    {
      value: 0,
      label: "全部",
    },
    {
      value: 1,
      label: "男",
    },
    {
      value: 2,
      label: "女",
    },
  ];
};

const search = (selectPosition) => {
  return () => {
    positionList({
      name: "",
      pageNo: 1,
      pageSize: 100,
    }).then((res) => {
      selectPosition.options = res.data.dataList.map((i) => {
        return {
          ...i,
          value: i.name,
        };
      });
    });
  };
};

export const searchRule = () => {
  const selectPosition = {
    type: "select",
    field: "position",
    title: "职务",
    options: [],
    props: {
      valueKey: "id",
    },
    on: {},
    value: "",
    col: {
      span: 4,
    },
  };
  selectPosition.on.focus = search(selectPosition);
  return [];
};

export const editRule = () => {
  return [
    {
      type: "hidden",
      hidden: true,
      tableVisible: false,
      title: "ID",
      field: "id",
      value: null,
    },
    {
      type: "input",
      field: "roleName",
      tableVisible: true,
      validate: {
        required: true,
        message: "请先填写角色名称!",
      },
      title: "角色名称",
      value: "",
    },
  ];
};
